<template>
  <div class="user-item-user" :id="data.id">
    <div class="cover">
      <img :src="data.cover" v-if="data.cover" class="image">
      <img v-else src="../assets/pp.jpg" class="image">
    </div>
    <div class="user-info">
      <div class="username">用户名: {{ data.username }}</div>
      <div class="blog-info" v-html="data.description"></div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  data: {
    type: Object,
  },
});
</script>

<style lang="scss">
.user-item-user {
  margin-bottom: 20px;
  display: flex;
  border-bottom: 1px solid #252525;
  padding-bottom: 10px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
  }

  .cover {
    width: 200px;
    height: 200px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 100%;
    transition: transform 0.3s ease;

    &:hover {
      transform: scale(1.1);
    }

    img {
      width: 100%;
      height: auto;
      object-fit: cover;
      opacity: 0;
      animation: fadeIn 1s forwards;
    }
  }

  .user-info {
    color: #363535;
    flex: 1;
    margin-left: 10px;

    .username {
      font-size: 18px;
      font-weight: 400;
      transition: color 0.3s ease;

      &:hover {
        color: #4caf50;
      }
    }

    .blog-info {
      margin-top: 10px;
      display: flex;
      font-size: 14px;
      line-height: 1.4;
      transition: color 0.3s ease;

      &:hover {
        color: #666;
      }
    }
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</style>
